#ifndef DB_H
#define DB_H
#include <QString>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QVariant>
class Db
{
public:
    static bool testDb(const QString &ip,const QString &port,const QString &name,const QString &user,const QString &password);
    static QStringList getCategoryName();
    static int getCategoryID(const QString &cname);
    static QSqlQuery getProductNameAndCno();
    static QSqlQuery getProductIfm(const QString &pname);
    static QSqlQuery getUserIfm(const QString &uname);
    static bool insertProduct(const QString &pname, const QString &paddress, const QString &pdesc, const QString &position, double price, int cno);
    static bool deleteProduct(const QString &pname);
    static bool insertCategory(const QString &cname, const QString &cdesc);
    static bool deleteCategory(const QString &cname);
    static bool changePassword(const QString &uname, const QString &oldpwd, const QString &newpwd);
    static bool insertUser(const QString &uname, const QString &pwd);
    static bool deleteUser(const QString &uname);
private:
    Db();
};

#endif // DB_H
